﻿function Text(position, size, text) {
    Node.apply(this, [document.createElementNS('http://www.w3.org/2000/svg', "text"), position, size]);

    this.onUpdateLayout = function () {
        this._domEl.setAttribute("x", this.getActualPosition().x);
        this._domEl.setAttribute("y", this.getActualPosition().y);
        this._domEl.innerHTML = this._text;
        if (this.logFlag) {
            worker.postMessage("Create a Text:" + this.getText());
        }
        this.logFlag = false;
    };
    this._text = text;
    this._domEl.style.fontSize = "12";
    this._domEl.style.fontFamily = "Verdana";
    this._domEl.style.fill = "black";

    this.getText = function () {
        return this._text;
    }

    this.setText = function (val) {
        this._text = val;
    }

    this.hitTest = function () {
        return new HitResult(false, 0, 0);
    }

    this.getCenterPos = function () {
        var x = this._position.x + (this._size.w) / 2;
        var y = this._position.y + (this._size.h) / 2;
        return { x: x, y: y };
    }
}